package operation.cust;

import operation.chef.Ioperation;
import zy.Cust;
import zy.Warehouse;

import java.util.Scanner;

/*
 *@Student 张策
 */
public class cust3 implements Ioperation2 {
    @Override
    public void work(Warehouse warehouse, Cust cust) {
        double money;
        Scanner scanner=new Scanner(System.in);
        System.out.println("请输入金额在0~500范围内");
        while (true){
        String mon=scanner.nextLine();
        while (!warehouse.isDouble(mon)){
            System.out.println("输入错误，请重新输入");
            mon=scanner.nextLine();
        }
         money=Double.parseDouble(mon);
        if(money>500){
            System.out.println("少爷小本生意，冲太多了");
        }else if(money<=0) {
            System.out.println("输入错误，请重新输入");
        }else if(money>0&&money<=500){
            //顾客的饭卡钱增多
            cust.setMoney(money+cust.getMoney());
            System.out.println("充值成功！开始消费！");
            //老板的钱增多
            warehouse.setMoney(warehouse.getMoney()+money);
            break;
        }
        }
    }
}
